<template>
	<view>
		<view class="nav2">
			<u-navbar title="售后服务" bgColor="transparent" :fixed="false" autoBack>
			</u-navbar>
		</view>
		<view class="m30">
			<view class="flex-au">
				<view v-for="(item,index) in navList" :key="index" class="c999 f28"
					:class="{'active pore':navIndex == index}" @click="navClick(index)">
					{{item.name}}
				</view>
			</view>
			<u-gap height="20"></u-gap>
			<view v-if="orderList.length">
				<view class="bgFff radius30 p30 mb20" v-for="(item,index) in orderList" :key="index">
					<view class="flex-jus f26">
						<text class="c999">订单号：{{item.orderCode}}</text>
						<text class="c343">{{item.createTime}}</text>
					</view>
					<u-gap height="10"></u-gap>
					<view v-if="item.orderType==3" @click="openUrl('/subpage/order/tuangouDetail?id='+item.id)">
						<view class="flex flex-start" v-if="item.orderPro && item.orderPro.icon">
							<u-image :src="api_host + item.orderPro.icon" mode="" width="76px" height="76px"
								radius="5"></u-image>
							<view class="p10 ml10 flex1">
								<view class="c343 f28 bold">{{item.orderPro.proName}}</view>
								<u-gap height="10"></u-gap>
							</view>
						</view>
					</view>
					<view v-else @click="openUrl('/subpage/order/detail?id='+item.id)">
						<view class="flex flex-start" v-if="item.orderPro && item.orderPro.icon">
							<u-image :src="api_host + item.orderPro.icon" mode="" width="76px" height="76px"
								radius="5"></u-image>
							<view class="p10 ml10 flex1">
								<view class="c343 f28 bold">{{item.orderPro.proName}}</view>
								<u-gap height="10"></u-gap>
								<view v-if="item.orderType!=3">
									<view class="flex-jus f24 c999 mb10" v-for="(item2,index2) in item.orderDetails"
										:key="index2">
										<text>{{item2.name}} x{{item2.buyCount}}</text>
										<!-- <text>¥ {{item2.price}}</text> -->
									</view>
								</view>
							</view>
						</view>
					</view>
					<u-gap height="10"></u-gap>
					<!-- <u-line color="#eee" margin="20rpx 0"></u-line>
					<view v-if="item.orderAppend" class="mb20" @click="openUrl('/subpage/order/detail?id='+item.id)">
						<view class="c343 f26">追加服务</view>
						<view class="bgF7 p10 radiusBox mt20 mb20">
							<view class="f24 c343 mt10 mb10">
								{{item.orderAppend.describe}}
							</view>
							<view class="flex" v-if="item.sceneImages">
								<view class="m10" v-for="(img,imgIndex) in item.sceneImages.split(',')" :key="index">
									<u-image :src="api_host + img" mode="" width="76px" height="76px"
										radius="5"></u-image>
								</view>
							</view>
						</view>
					</view> -->
					<view class="flex jus-right">
						<view v-if="item.isAfter == 0 && item.orderType==3 && item.goodsInfo.isAfterSale==0">
							<u-button shape="circle" color="#fff"
								@click="openUrl('/subpage/order/tuangouDetail?id='+item.id)"
								:customStyle="{'color':'#34314F','border':'1px solid #ddd','height':'70rpx','fontSize':'24rpx'}">
								申请售后
							</u-button>
						</view>
						<view v-if="item.orderType==3 && item.goodsInfo.isAfterSale==1">
							<u-button shape="circle" color="#fff"
								:customStyle="{'color':'#34314F','border':'1px solid #ddd','height':'70rpx','fontSize':'24rpx'}">该商品不支持售后</u-button>
						</view>
						<view v-if="item.isAfter == 0 && item.orderType!=3">
							<u-button shape=" circle" color="#fff"
								@click="openUrl('/subpage/service/apply?id='+item.id+'&price='+item.orderPrice)"
								:customStyle="{'color':'#34314F','border':'1px solid #ddd','height':'70rpx','fontSize':'24rpx'}">
								申请售后
							</u-button>
						</view>
						<view v-if="item.isAfter == 1">
							<u-button shape="circle" color="#fff"
								@click="openUrl('/subpage/service/detail?id='+item.id)"
								:customStyle="{'color':'#34314F','border':'1px solid #ddd','height':'70rpx','fontSize':'24rpx'}">
								售后中
							</u-button>
						</view>
						<view v-if="item.isAfter == 2">
							<u-button shape="circle" color="#fff"
								@click="openUrl('/subpage/service/detail?id='+item.id)"
								:customStyle="{'color':'#34314F','border':'1px solid #ddd','height':'70rpx','fontSize':'24rpx'}">
								查看售后
							</u-button>
						</view>
					</view>
				</view>
			</view>
			<view v-else class="no-data">
				<text>暂无数据</text>
			</view>
		</view>
		<u-gap height="20"></u-gap>
	</view>
</template>

<script>
	import {
		getSalesorder
	} from '@/common/api_order.js'
	export default {
		name: '',
		data() {
			return {
				navList: [{
						name: '售后申请',
						value: '0'
					},
					{
						name: '处理中',
						value: '1'
					},
					{
						name: '已完成',
						value: '2'
					}
				],
				orderList: [],
				navIndex: 0
			}
		},
		onLoad(option) {

		},
		onShow() {
			this.getSalesorder()
		},
		methods: {
			navClick(index) {
				this.navIndex = index
				this.getSalesorder()
			},
			async getSalesorder() { //订单列表
				uni.showLoading({
					mask: true
				})
				const res = await getSalesorder({
					type: this.navList[this.navIndex].value
				})
				if (res.code == 200) {
					this.orderList = res.data
				}
				uni.hideLoading()
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FEF4E8;
	}

	.active {
		color: #34314F;
		font-weight: bold;
		z-index: 10;
	}

	.active::after {
		position: absolute;
		content: '';
		left: -20rpx;
		top: 0;
		height: 100%;
		width: 100rpx;
		border-radius: 30rpx;
		background-color: #FEF4E8;
		background-image: linear-gradient(to right, #FFDE6D, #FFF1A6);
		z-index: -1;
	}
	.no-data {
		position: absolute;
		top: 40%;
		left: 50%;
		transform: translate(-50%, -50%);
		margin: 0;
	}
</style>